package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.SignalMachineHandleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by ding on 2017/7/22.
 */
@Controller
@RequestMapping("/rds_signalMachineHandle")
public class SignalMachineHandleController {
    @Resource
    private SignalMachineHandleService signalMachineHandleService;

    @RequestMapping(value = "/getSignalMachine4DT")
    @ResponseBody
    public DTResponseDto getSignalMachine4DT(DTRequestDto dtRequestDto, String actorIds , Integer orgId, Integer machineMaintenanceStatus) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = signalMachineHandleService.getSignalMachine4DT(dtRequestDto,actorIds, orgId,machineMaintenanceStatus);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping("/addMachineMaintenanceContent")
    @ResponseBody
    public JsonMsgDto addMachineMaintenanceContent(Integer machineFaultId, String machineMaintenanceContent) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalMachineHandleService.addMachineMaintenanceContent(machineFaultId, machineMaintenanceContent));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/finishMachineMaintenance")
    @ResponseBody
    public JsonMsgDto finishMachineMaintenance(String machineMaintenancePhoto,Integer machineMaintainerId,String machineMaintenanceTime,String machineMaintenanceExplain,Integer machineFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalMachineHandleService.finishMachineMaintenance(machineMaintenancePhoto,machineMaintainerId,machineMaintenanceTime,machineMaintenanceExplain,machineFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getMachineFaultHandleList4App")
    @ResponseBody
    public JsonMsgDto getMachineFaultHandleList4App(Integer orgId,Integer maintenanceStatus,String actorIds,Integer count,Integer size) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalMachineHandleService.getMachineFaultHandleList4App(orgId, maintenanceStatus, actorIds, count, size));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getMachineReceiptInfo4App")
    @ResponseBody
    public JsonMsgDto getReceiptInfo4App(Integer machineFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(signalMachineHandleService.getMachineReceiptInfo4App(machineFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }
}
